package com.milling.web.controller.business;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.milling.common.annotation.Log;
import com.milling.common.core.controller.BaseController;
import com.milling.common.core.domain.AjaxResult;
import com.milling.common.enums.BusinessType;
import com.milling.business.domain.WmsConfigSub;
import com.milling.business.service.IWmsConfigSubService;
import com.milling.common.utils.poi.ExcelUtil;
import com.milling.common.core.page.TableDataInfo;

/**
 * 配针托盘信息Controller
 *
 * @author X
 * @date 2025-03-18
 */
@RestController
@RequestMapping("/business/configsub")
public class WmsConfigSubController extends BaseController
{
    @Autowired
    private IWmsConfigSubService wmsConfigSubService;

    /**
     * 查询配针托盘信息列表
     */
    @PreAuthorize("@ss.hasPermi('business:configsub:list')")
    @GetMapping("/list")
    public TableDataInfo list(WmsConfigSub wmsConfigSub)
    {
        startPage();
        List<WmsConfigSub> list = wmsConfigSubService.selectWmsConfigSubList(wmsConfigSub);
        return getDataTable(list);
    }

    /**
     * 导出配针托盘信息列表
     */
    @PreAuthorize("@ss.hasPermi('business:configsub:export')")
    @Log(title = "配针托盘信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WmsConfigSub wmsConfigSub)
    {
        List<WmsConfigSub> list = wmsConfigSubService.selectWmsConfigSubList(wmsConfigSub);
        ExcelUtil<WmsConfigSub> util = new ExcelUtil<WmsConfigSub>(WmsConfigSub.class);
        util.exportExcel(response, list, "配针托盘信息数据");
    }

    /**
     * 获取配针托盘信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('business:configsub:query')")
    @GetMapping(value = "/{configSubId}")
    public AjaxResult getInfo(@PathVariable("configSubId") Long configSubId)
    {
        return success(wmsConfigSubService.selectWmsConfigSubByConfigSubId(configSubId));
    }

    /**
     * 新增配针托盘信息
     */
    @PreAuthorize("@ss.hasPermi('business:configsub:add')")
    @Log(title = "配针托盘信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WmsConfigSub wmsConfigSub)
    {
        return toAjax(wmsConfigSubService.insertWmsConfigSub(wmsConfigSub));
    }

    /**
     * 修改配针托盘信息
     */
    @PreAuthorize("@ss.hasPermi('business:configsub:edit')")
    @Log(title = "配针托盘信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WmsConfigSub wmsConfigSub)
    {
        return toAjax(wmsConfigSubService.updateWmsConfigSub(wmsConfigSub));
    }

    /**
     * 删除配针托盘信息
     */
    @PreAuthorize("@ss.hasPermi('business:configsub:remove')")
    @Log(title = "配针托盘信息", businessType = BusinessType.DELETE)
    @DeleteMapping("/{configSubIds}")
    public AjaxResult remove(@PathVariable Long[] configSubIds)
    {
        return toAjax(wmsConfigSubService.deleteWmsConfigSubByConfigSubIds(configSubIds));
    }
}
